# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This package has the integration tests along with the utilities for testing NSF in PINs.

package(
    default_visibility = ["//visibility:public"],
    licenses = ["notice"],
)

cc_library(
    name = "compare_p4flows",
    testonly = True,
    srcs = ["compare_p4flows.cc"],
    hdrs = ["compare_p4flows.h"],
    deps = [
        "@com_github_google_glog//:glog",
        "//gutil/gutil:status",
        "@com_github_p4lang_p4runtime//:p4runtime_cc_proto",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings:string_view",
        "@com_google_protobuf//:protobuf",
    ],
)

cc_test(
    name = "compare_p4flows_test",
    timeout = "long",
    srcs = ["compare_p4flows_test.cc"],
    deps = [
        ":compare_p4flows",
        "//gutil/gutil:status_matchers",
        "//gutil/gutil:testing",
        "@com_github_p4lang_p4runtime//:p4runtime_cc_proto",
        "@com_google_absl//absl/status",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_library(
    name = "util",
    testonly = True,
    srcs = ["util.cc"],
    hdrs = ["util.h"],
    deps = [
        "//gutil/gutil:overload",
        "//gutil/gutil:status",
        "//gutil/gutil:testing",
        "//lib/gnmi:gnmi_helper",
        "//lib/utils:generic_testbed_utils",
        "//lib/validator:validator_lib",
        "//p4_pdpi:ir",
        "//p4_pdpi:p4_runtime_session",
        "//p4_pdpi:p4_runtime_session_extras",
        "//p4_pdpi:pd",
        "//p4_pdpi:sequencing",
        "//sai_p4/instantiations/google:sai_pd_cc_proto",
        "//sai_p4/instantiations/google/test_tools:table_entry_generator",
        "//tests/integration/system/nsf/interfaces:component_validator",
        "//tests/integration/system/nsf/interfaces:image_config_params",
        "//tests/integration/system/nsf/interfaces:testbed",
        "//tests/lib:switch_test_setup_helpers",
        "//thinkit:generic_testbed",
        "//thinkit:generic_testbed_fixture",
        "//thinkit:mirror_testbed",
        "//thinkit:mirror_testbed_fixture",
        "//thinkit:ssh_client",
        "//thinkit:switch",
        "@com_github_google_glog//:glog",
        "@com_github_grpc_grpc//:grpc++",
        "@com_github_p4lang_p4runtime//:p4runtime_cc_proto",
        "@com_google_absl//absl/base:nullability",
        "@com_google_absl//absl/random",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:string_view",
        "@com_google_absl//absl/time",
        "@com_google_absl//absl/types:span",
        "@com_google_protobuf//:protobuf",
    ],
)

cc_library(
    name = "upgrade_test",
    testonly = True,
    srcs = ["upgrade_test.cc"],
    hdrs = ["upgrade_test.h"],
    deps = [
        ":compare_p4flows",
        ":milestone",
        ":util",
        "//gutil/gutil:proto",
        "//gutil/gutil:status_matchers",
        "//lib/gnmi:gnmi_helper",
        "//tests/integration/system/nsf/interfaces:component_validator",
        "//tests/integration/system/nsf/interfaces:flow_programmer",
        "//tests/integration/system/nsf/interfaces:image_config_params",
        "//tests/integration/system/nsf/interfaces:scenario",
        "//tests/integration/system/nsf/interfaces:test_params",
        "//tests/integration/system/nsf/interfaces:testbed",
        "//tests/integration/system/nsf/interfaces:traffic_helper",
        "//thinkit:ssh_client",
        "//thinkit:switch",
        "//thinkit:test_environment",
        "//thinkit/proto:generic_testbed_cc_proto",
        "@com_github_google_glog//:glog",
        "@com_github_p4lang_p4runtime//:p4info_cc_proto",
        "@com_github_p4lang_p4runtime//:p4runtime_cc_proto",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/flags:flag",
        "@com_google_absl//absl/random",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
        "@com_google_absl//absl/strings:string_view",
        "@com_google_absl//absl/time",
        "@com_google_googletest//:gtest",
    ],
    alwayslink = True,
)

cc_library(
    name = "milestone",
    srcs = ["milestone.cc"],
    hdrs = ["milestone.h"],
    deps = [
        "@com_github_google_glog//:glog",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:string_view",
    ],
)

cc_library(
    name = "nsf_acl_flow_coverage_test",
    testonly = True,
    srcs = ["nsf_acl_flow_coverage_test.cc"],
    hdrs = ["nsf_acl_flow_coverage_test.h"],
    deps = [
        ":compare_p4flows",
        ":util",
        "//gutil/gutil:status_matchers",
        "//sai_p4/instantiations/google:sai_pd_cc_proto",
        "//tests/integration/system/nsf/interfaces:component_validator",
        "//tests/integration/system/nsf/interfaces:flow_programmer",
        "//tests/integration/system/nsf/interfaces:image_config_params",
        "//tests/integration/system/nsf/interfaces:test_params",
        "//tests/integration/system/nsf/interfaces:testbed",
        "//tests/integration/system/nsf/interfaces:traffic_helper",
        "//thinkit:ssh_client",
        "//thinkit:switch",
        "//thinkit:test_environment",
        "@com_github_google_glog//:glog",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@com_google_googletest//:gtest_main",
    ],
    alwayslink = True,
)

cc_library(
    name = "nsf_link_flap_test",
    testonly = True,
    srcs = ["nsf_link_flap_test.cc"],
    hdrs = ["nsf_link_flap_test.h"],
    deps = [
        ":util",
        "//gutil/gutil:status",
        "//gutil/gutil:status_matchers",
        "//gutil/gutil:testing",
        "//tests/gnmi:util",
        "//tests/integration/system/nsf/interfaces:image_config_params",
        "//tests/integration/system/nsf/interfaces:testbed",
        "//thinkit:generic_testbed",
        "//thinkit:generic_testbed_fixture",
        "//thinkit:ssh_client",
        "//thinkit:switch",
        "//thinkit/proto:generic_testbed_cc_proto",
        "@com_github_gnmi//proto/gnmi:gnmi_cc_grpc_proto",
        "@com_github_google_glog//:glog",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/container:flat_hash_set",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings:string_view",
        "@com_google_absl//absl/time",
        "@com_google_googletest//:gtest_main",
    ],
    alwayslink = True,
)

cc_library(
    name = "nsf_dynamic_state_update_test",
    testonly = True,
    srcs = ["nsf_dynamic_state_update_test.cc"],
    hdrs = ["nsf_dynamic_state_update_test.h"],
    deps = [
        ":util",
        "//gutil/gutil:status_matchers",
        "//lib/gnmi:gnmi_helper",
        "//tests/gnmi:util",
        "//tests/integration/system/nsf/interfaces:testbed",
        "//thinkit:generic_testbed_fixture",
        "//thinkit:mirror_testbed",
        "//thinkit:mirror_testbed_fixture",
        "//thinkit:ssh_client",
        "//thinkit:switch",
        "//thinkit/proto:generic_testbed_cc_proto",
        "@com_github_google_glog//:glog",
        "@com_google_absl//absl/random",
        "@com_google_absl//absl/strings:string_view",
        "@com_google_absl//absl/time",
        "@com_google_googletest//:gtest_main",
    ],
    alwayslink = True,
)

cc_library(
    name = "nsf_concurrent_config_push_flow_programming_test",
    testonly = True,
    srcs = ["nsf_concurrent_config_push_flow_programming_test.cc"],
    hdrs = ["nsf_concurrent_config_push_flow_programming_test.h"],
    deps = [
        ":compare_p4flows",
        ":util",
        "//gutil/gutil:status_matchers",
        "//lib/gnmi:gnmi_helper",
        "//p4_pdpi:ir_cc_proto",
        "//sai_p4/instantiations/google:sai_pd_cc_proto",
        "//tests/integration/system/nsf/interfaces:component_validator",
        "//tests/integration/system/nsf/interfaces:flow_programmer",
        "//tests/integration/system/nsf/interfaces:image_config_params",
        "//tests/integration/system/nsf/interfaces:test_params",
        "//tests/integration/system/nsf/interfaces:testbed",
        "//tests/integration/system/nsf/interfaces:traffic_helper",
        "//thinkit:ssh_client",
        "//thinkit:switch",
        "//thinkit:test_environment",
        "@com_github_google_glog//:glog",
        "@com_google_absl//absl/random",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/time",
        "@com_google_googletest//:gtest_main",
    ],
    alwayslink = True,
)
